home *** CD-ROM | disk | FTP | other *** search
/ .net 2002 March / DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin / pc / PC Software / Coldfusion / coldfusion-60-win-en.exe / results.cfm1 < prev    next >
Encoding:
Text File  |  2002-04-04  |  2.8 KB  |  104 lines

  1. le>
  2.  
  3. <input type="submit" name="submit" value="Convert Temperature">
  4.  
  5. </cfform>
  6.  
  7. </cfmodule><!--- 
  8. **
  9. * CFMX Example Applications
  10. *
  11. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  12. *
  13. * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
  14. * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
  15. *
  16. **
  17.  --->
  18.  
  19. <cfmodule template="../tags/layout.cfm" pageName="Custom Tags Example - Page Source">
  20.  
  21.     <cfset variables.files = "index.cfm,tempconverter.cfm">
  22.  
  23.     <cfinclude template="../tags/showsource.cfm">
  24.  
  25. </cfmodule>
  26.  
  27. <!--- 
  28. **
  29. * CFMX Example Applications
  30. *
  31. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  32. *
  33. * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
  34. * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
  35. *
  36. **
  37.  --->
  38.  
  39. <!--- 
  40.     Require Attributes.Temperature 
  41.     The attributes scope is a special scope for custom tags. It
  42.     contains any data passed to the custom tag.
  43. --->
  44. <cfif not isDefined("attributes.temperature") or not IsNumeric(attributes.temperature)>
  45.     <!--- Display an error message for the user. --->
  46.     <cfoutput>
  47.     <p>
  48.     <b>TempConverter Error:</b> You must pass the "Temperature" attribute. This value must be a number.
  49.     </p>
  50.     </cfoutput>
  51.     <cfabort>
  52. </cfif>
  53.  
  54. <!--- 
  55.     Require scale. This tell us what we are converting FROM.
  56.     Valid values are:
  57.         F or Fahrenheit
  58.         C or Celsius
  59. --->
  60. <cfif not isDefined("attributes.scale") or not listFindNoCase("f,fahrenheit,c,celsius",attributes.scale)>
  61.     <!--- Display an error message for the user. --->
  62.     <cfoutput>
  63.     <p>
  64.     <b>TempConverter Error:</b> You must pass the "Scale" attribute. This value must be one of the following: F,Fahrenheit,C,Celsius.
  65.     </p>
  66.     </cfoutput>
  67.     <cfabort>
  68. </cfif>
  69.  
  70. <!---
  71.     This custom tag needs to return it's value to the calling template.
  72.     It allows the user to specify what the name of the returned value is.
  73.     If the user doesn't specify the variable name, we default to 'temperature'.
  74.     We use CFPARAM to default this, as well as to check for a valid variable name
  75.     if the use passes one in.
  76. --->
  77. <cfparam name="attributes.returnVariable" default="temperature" type="variablename">
  78.  
  79. <cfswitch expression="#attributes.scale#">
  80.  
  81.     <cfcase value="F,Fahrenheit">
  82.         <cfset returnVal = (attributes.temperature-32.0) * (5.0/9.0)>
  83.     </cfcase>
  84.     
  85.     <cfcase value="C,Celsius">
  86.         <cfset returnVal = (attributes.temperature * 9.0/5.0) + 32>
  87.     </cfcase>
  88.     
  89. </cfswitch>    
  90.  
  91. <!--- 
  92.     We now return the value to the user. We use the setVariable function
  93.     to write to the caller scope, which is the local scope of the template
  94.     that called us.
  95. --->
  96.  
  97. <cfset setVariable("Caller.#attributes.returnVariable#",returnVal)><!--- 
  98. **
  99. * CFMX Example Applications
  100. *
  101. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  102. *
  103. * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
  104. * TERMS AND CONDITIONS SET FORTH IN THE CORRESPOND